//
//  TransactViewController.m
//  KD
//
//  Created by Hubery on 15/8/14.
//  Copyright (c) 2015年 centling. All rights reserved.
//

#import "TransactLoginViewController.h"

@interface TransactLoginViewController ()
- (IBAction)back:(id)sender;
- (IBAction)login:(id)sender;
@property (weak, nonatomic) IBOutlet UITextField *userName;
@property (weak, nonatomic) IBOutlet UITextField *pwd;
- (IBAction)autoLoginBtn:(UIButton *)sender;
@property (weak, nonatomic) IBOutlet UIButton *autoLoginBtn;


@end

@implementation TransactLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.autoLoginBtn.layer.borderWidth = 1;
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    self.autoLoginBtn.selected = [user objectForKey:@"autoLogin"];
}

- (IBAction)back:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (IBAction)login:(id)sender {
    if (([self.userName.text  isEqual: @"1"])&&([self.pwd.text  isEqual: @"1"])) {
        [self performSegueWithIdentifier:@"TransactLogin" sender:@"xxx"];
    }else{
        [GlobalUtil HUDShowMessage:@"用户名或密码不正确" addedToView:SharedAppDelegate.window];
    }
}

- (IBAction)autoLoginBtn:(UIButton *)sender {
    self.autoLoginBtn.selected = !sender.selected;
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    [user setBool:self.autoLoginBtn.selected forKey:@"autoLogin" ];
    [user synchronize];
}
@end
